#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>

char*  f(char* s,int left,int right,int *size){
    if( left == right )
        return s+left;
    int mid=left+(right-left)/2;
    int sum=left+right;
    int r=0;
    if( (right-left) % 2 == 0 )
        r--;
    int i;
    for(i=mid; i>=left; i-- ){
        if( s[i] == s[sum-i] )
            r+=2;
        else
            break;
    }
    *size=r;
    return s+i+1;
}
char* longestPalindrome(char* s) {
    char *ret=NULL,*tmp=NULL;
    int t,r=0,len=strlen(s);
    for(int l=len; l>0; l--) {
        if( r>=l )
            break;
        for( int left=0; left+l-1 < len; left++ ) {
            tmp=f(s,left,left+l-1,&t);
            if( t > r ){
                ret=tmp;
                r=t;
            }
        }
    }
    char *b=malloc(sizeof(char)*r);
    memcpy(b,ret,r);
    printf("%s\n",b);
    return b;
}

int main(){
    char t[]="a";
    printf("%s\n",t);
    longestPalindrome(t);
    return 0;
}
